# -*- coding: utf-8 -*-
"""
 @Time    : 2021/1/21 下午6:18
 @Author  : tgy
 
"""
import re

text = 'UPPER PYTHON, lower python, Mixed Python'


def transfer(word):
    def inner(res):
        ...
        rs = res.group()
        if rs.isupper():
            return word.upper()
        elif rs.islower():
            return word.lower()
        elif rs[0].isupper():
            return word.capitalize()
        else:
            return word
    return inner


def test01():
    ...
    pattern = re.compile('python', re.IGNORECASE)
    print(pattern.findall(text))
    print(pattern.sub(transfer('tgy'), text))


if __name__ == '__main__':
    ...
    test01()
